﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Logistics.DAL
{
    public class UserInfoDAL
    {
        public static Model.UserInfo L(string n,string p)
        {
            string sql = "select * from [User] where UserName=@UserName and Password=@Password";
            SqlParameter[] pms = new SqlParameter[]
            {
                new SqlParameter("@UserName",n),
                new SqlParameter("@Password",p)
            };
            SqlDataReader reader = SqlHelper.ExecuteReader(sql, pms);
            List<Model.UserInfo> lst = new List<Model.UserInfo>();
            while (reader.Read())
            {
                Model.UserInfo u = new Model.UserInfo();
                u.UserName = reader["UserName"].ToString();
                u.Password = reader["Password"].ToString();
                lst.Add(u);
            }
            reader.Close();
            if (lst.Count>0)
            {
                return lst[0];
            }
            else
            {
                return null;
            }
        }
    }
}
